package company.GuangLianDa;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @ClassName P3
 * @Description
 * @Company inspur
 * @Author Kevin
 * @Date 2020/7/31 22:00
 * @Version 1.0
 */
public class P3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        Node[] monsters = new Node[n];
        for (int i = 0; i < n; i++) {
            monsters[i].x = sc.nextInt();
            monsters[i].hp = sc.nextInt();
        }
        sc.close();

        Arrays.sort(monsters, new Comparator<Node>() {
            @Override
            public int compare(Node o1, Node o2) {
                return o1.x - o2.x;
            }
        });

        int res = 0, left = 0;
        while (left < n) {
            int kill = monsters[left].hp;
            res += kill;

            int j = left + 1;
            while (monsters[j].x <= 2*y + monsters[left].x) {
                monsters[j].hp -= kill;
                j++;
            }

            int k = left + 1;
            while (monsters[k].hp <= 0) {
                k++;
            }

            left = k;
        }

        System.out.println(res);
    }

    class Node {
        int x;
        int hp;
    }
}
